Functional Enrichment Analysis | Tool: gprofileR | Let’s put it all together!
Previous script is here.
load(paste0(fea_output, "gprofiler_end.Rdata"))
g_res_end <- ldply(output_df, data.frame) # like rbind
g_res_end$net = "end"
rm(output_df)
load(paste0(fea_output, "gprofiler_opc.Rdata"))
g_res_opc <- ldply(output_df, data.frame) # like rbind
g_res_opc$net = "opc"
rm(output_df)
load(paste0(fea_output, "gprofiler_mic.Rdata"))
g_res_mic <- ldply(output_df, data.frame)
g_res_mic$net = "mic"
rm(output_df)
load(paste0(fea_output, "gprofiler_ast.Rdata"))
g_res_ast <- ldply(output_df, data.frame)
g_res_ast$net = "ast"
rm(output_df)
load(paste0(fea_output, "gprofiler_oli.Rdata"))
g_res_oli <- ldply(output_df, data.frame)
g_res_oli$net = "oli"
rm(output_df)
load(paste0(fea_output, "gprofiler_inh.Rdata"))
g_res_inh <- ldply(output_df, data.frame)
g_res_inh$net = "inh"
rm(output_df)
load(paste0(fea_output, "gprofiler_ext.Rdata"))
g_res_ext <- ldply(output_df, data.frame)
g_res_ext$net = "ext"
rm(output_df)
g_all = rbind(g_res_end, g_res_opc, g_res_mic, g_res_ast, g_res_oli, g_res_inh, g_res_ext)
g_all$module = paste0(g_all$net,"_", g_all$query)
g_all$.id = NULL
message(paste0("Number of modules enriched: ", length(unique(g_all$module)))) Term present in one cell type
g_all$term_clean = g_all$term_name
g_all$term_clean = ifelse(grepl("immune",tolower(g_all$term_clean)),"immune",g_all$term_clean)
g_all$term_clean = ifelse(grepl("phagocytosis",tolower(g_all$term_clean)),"phagocytosis",g_all$term_clean)
g_all$term_clean = ifelse(grepl("mitoch",tolower(g_all$term_clean)),"mitochondria",g_all$term_clean)
g_all$term_clean = ifelse(grepl("ribosom",tolower(g_all$term_clean)),"ribosome",g_all$term_clean)
g_all$term_clean = ifelse(grepl("proteaso",tolower(g_all$term_clean)),"proteasome",g_all$term_clean)
g_all$term_clean = ifelse(grepl("protein transport",tolower(g_all$term_clean)),"protein transport",g_all$term_clean)
g_all$term_clean = ifelse(grepl("golgi",tolower(g_all$term_clean)),"golgi",g_all$term_clean)
g_all$term_clean = ifelse(grepl("mapk",tolower(g_all$term_clean)),"MAPK",g_all$term_clean)
g_all_filt <- g_all %>% filter(source %in% c(
"WP"
,"KEGG"
,"REAC"
,"GO:BP"
,"GO:MF"
,"GO:CC"
)) %>%
group_by(term_clean) %>%
dplyr::summarise(n_modules = length(unique(module)),
n_cell = length(unique(net)),
celltypes = paste(unique(net),collapse = ";")) %>%
arrange(n_modules)
# One cell type only
createDT(g_all_filt %>%
filter(n_cell == 1))R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Stream 8
Matrix products: default BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.15.so
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] dplyr_1.0.8 plyr_1.8.6
loaded via a namespace (and not attached): [1] Rcpp_1.0.8
rstudioapi_0.13 knitr_1.37 magrittr_2.0.3
[5] tidyselect_1.1.2 R6_2.5.1 rlang_1.1.1 fastmap_1.1.0
[9] fansi_1.0.4 stringr_1.4.0 tools_4.1.2 DT_0.30
[13] xfun_0.29 utf8_1.2.3 DBI_1.1.2 cli_3.6.1
[17] jquerylib_0.1.4 crosstalk_1.2.0 htmltools_0.5.2 assertthat_0.2.1
[21] yaml_2.3.5 digest_0.6.29 tibble_3.2.1 lifecycle_1.0.3
[25] purrr_0.3.4 htmlwidgets_1.5.4 sass_0.4.0 vctrs_0.6.3
[29] glue_1.6.2 evaluate_0.15 rmarkdown_2.11 stringi_1.7.6
[33] compiler_4.1.2 bslib_0.3.1 pillar_1.9.0 generics_0.1.2
[37] jsonlite_1.7.3 pkgconfig_2.0.3